<?
$r = "../";
/*
----------------------------------------
-----    Page logic description    -----
----------------------------------------
INPUT:
	action	=> one of {"edit", "pause", "resume", "delete"}
	mid		=> monitor id

OUTPUT:
	perform action and redirect to another page

DEBUG:
http://localhost/w3monitor/members/quick_actions.php?action=resume&mid=5
http://localhost/w3monitor/members/quick_actions.php?action=edit&mid=5
*/

require_once($r."_engine/header_nocache.php");
require_once($r."_engine/functions.php");
require_once($r."_engine/c_account.php");
require_once($r."_site_struct.php");
$account = GetActiveAccount();


if (!isset($action) || !isset($mid)) {
    die("Error: incorrect data.");
}

if ($action == "delete" && @$ack != "yes") {
	generate_html_redirect($r."members/quick_actions_delete.php?action=$action&mid=$mid");
}


$u = array();

if ($action == "pause") {
	/* clear "active" bit in status word */
	$u["status"] = "status & ~" . MONITOR_STATUS_IS_ACTIVE_MASK;
}
if ($action == "resume") {
	/* set "active" and clear "error" bits in status word */
	$u["status"] = "(status | " . MONITOR_STATUS_IS_ACTIVE_MASK . ") & (~ ".MONITOR_STATUS_IS_ERROR_MASK.")";
}

if (count($u) > 0) {
	$g_st_monitor->UpdateWithoutEncoding($u, array(@$mid));
}

if ($action == "delete") {
	$g_st_monitor->Delete(array(@$mid));
}


if ($action == "edit") {
    generate_html_redirect($r."members/dashboard.php?em_action=$action&em_mid=$mid#aMon_$mid");
}

generate_html_redirect($r."members/dashboard.php");
?>